package com.example.basicdemo.model.result;

import com.alibaba.fastjson.TypeReference;
import com.example.basicdemo.model.domain.SysRoleDomain;
import com.example.basicdemo.model.response.ListRoleAclResponse;
import com.isyscore.os.dev.api.IsyscoreResult;
import com.isyscore.os.dev.util.IsyscoreJsonUtil;
import com.isyscore.os.dev.util.StringUtils;

import java.util.List;

public class ListRoleAclResult implements IsyscoreResult<SysRoleDomain> {

    private ListRoleAclResponse response;

    public ListRoleAclResult(ListRoleAclResponse response) {
        this.response = response;
    }

    public ListRoleAclResponse getResponse() {
        return response;
    }

    public void setResponse(ListRoleAclResponse response) {
        this.response = response;
    }

    @Override
    public boolean isSuccess() {
        return response == null ? false : response.isSuccess();
    }

    @Override
    public SysRoleDomain parseData() {
        return null;
    }

    @Override
    public List<SysRoleDomain> parseListData() {
        String body = response.getBody();
        if (!StringUtils.isEmpty(body)) {
            return IsyscoreJsonUtil.parseObjectForListResult(body, new TypeReference<List<SysRoleDomain>>() {
            });
        }
        return null;
    }
}
